#include <bits/stdc++.h>
using namespace std;

const int N=2e5+50;
int t,n,a[N],cnt[N],c[N],ans;
void dfs(int pos){
    if(pos==n){
        int cal=0;
        for(int i=1;i<=n;i++){
            for(int j=i-1;j>0;j--){
                if(c[i]==c[j]){
                    if(a[i]==a[j])cal+=a[i];
                }
            }
        }
        ans=max(cal,ans);
        return;
    }
    c[pos]=1;
    dfs(pos+1);
    c[pos]=0;
    dfs(pos+1);
}



int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    while(t--){
        ans=0;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        dfs(1);
        cout<<ans<<'\n';
    }

    return 0;
}
